uses vector,stl_base, stlmain,Stl_types;
{$IFDEF WIN32}
{$APPTYPE CONSOLE}
{$ENDIF}
Type Tcontainer = Tvector;
var
  a:Tcontainer;
  i:longint;
  procedure objDump(var b: Tcontainer);
  begin
    writeln('SIZE = ', b.size);
    if (b = nil) then
      writeln('Not Created');
    if (b.Empty) then
      writeln('Empty');
    
  end;
procedure _InsertTest(var a: Tcontainer);
begin
	writeln('Test is  Insert Test ');
	a.clear();
	a.insert(20, 1);
	if (a.get(1) = 20) then writeln('Simple is  passed')
	else
		writeln('Simple not passed');
	a.insert(20, 33);
	if (a.get(2) <> 33) then writeln('Clever is passed')
	else
		writeln('Clever not passed');
  a.insert(10, 1);
  if (a.get(1) = 10) then writeln('Simple is  passed')
	else
		writeln('Simple not passed');
	a.clear(); 
end;


procedure _pushTest(var a: Tcontainer);
begin
	writeln('Test is  Insert Test ');
	a.clear();
	a.push_back(20);
  a.push_back(30);
  a.push_back(30);
	a.clear(); 
end;

procedure _FindTest(var a: Tcontainer);
var
	it: Iterator;
begin
	writeln('Test is Find Test');
	a.clear();
	a.insert(20, 1);
	a.insert(30, 2);
	a.insert(2000, 3);
	a.insert(2002, 4);
	a.insert(0,5);
	a.insert(20, 6);
	it := a.find(20);
	if (it <> nil) and (it^.data = 20) then writeln('Simple is passed')
	else
		writeln('Simple not passed');
    
	it := a.find(2000);
	if (it <> nil) and (it^.data = 2000) then writeln('Simple is passed')
	else
		writeln('Simple not passed');

	it := a.find(-2000);
	if (it = nil)then writeln('Simple is passed')
	else
		writeln('Simple not passed');

	it := a.find(0);
	if (it <> nil) and (it^.data = 0) then writeln('Simple is passed')
	else
		writeln('Simple not passed');

 
end;

procedure Do_Nothing;
begin
end;

procedure _ReverseTest(var a:Tcontainer);
const maxn = 1;
var
	b: array[1..20] of Longint;
	i: longint;
begin
  fillchar(b, sizeof(b), 0);
  a.Clear;
	writeln('Test is Reverse Test');
	for i := 1 to maxn do
	begin
		b[i] := random(201) -100;
		a.insert(b[i], i);
	end;
  for i := 1 to maxn do
    write(a.get(i) , ' ');
  writeln;
  writeln('After reversed');
	a.reverse();
  for i := 1 to maxn do
    write(a.get(i) , ' ');
	for i := maxn downto 1 do
	begin
		if (a.get(i) <> _none)and(a.get(i) = b[maxn + 1 -i]) then
				Do_Nothing
		else
			begin
				writeln('Test not passed');
				exit;
			end;
	end;
	writeln('Test Passed');

end;

procedure _DeleteTest(var a: Tcontainer);
begin
  a.Clear;
  writeln('Test is Delete Test');
	a.insert(1,1);
	a.insert(2,2);
	a.insert(3,2);
	a.delete(2);
	if (a.get(2) = 3)  then
		writeln('Test passed')
	else
		writeln('Test not passed');
end;

begin
  a:= Tvector.create;
  objDump(a);
  _insertTest(a);
  _FindTest(a);
  _ReverseTest(a);
  _DeleteTest(a);
end.
